﻿//----------------------------------------------------------------------------
// Copyright (c) Pavel Tishkin 2012-2013.
//
// You must not remove this notice, or any other, from this software.
//----------------------------------------------------------------------------

namespace Lib.Dxp.Orm


open System.Reflection


/// Depricated class. Simila functionality can be archived thre ExtTable

/// Has Document storage as "ExtendInfo" AS TEXT field 
type OneTable () = 
    inherit DocumentTable ()


    
    /// Serialize all dynamic field independ of their state to JSON view
    ///     TODO: not save this info if no changed was made in dynaimc fields
    member this.save_DynamicAsJson(_) = 
        let isDynamicChanged, dict = this.get_dynamicValuesAsDict()
        ServiceStack.Text.StringExtensions.ToJson dict
        

    
       
    /// Restore dynamic fields for current object from JSON view
    member this.load_DynamicFromJson<'a>(s : string) =    
        let props = this.CollectedFields()
        let dict : System.Collections.Generic.Dictionary<string, obj> = 
                ServiceStack.Text.JsonSerializer.DeserializeFromString(s, typeof<System.Collections.Generic.Dictionary<string, obj>>) |> unbox 
        this.load_AnyFromDict dict



    override x.save   () = 0    // current or generated Id
    override x.load   id  = ()
    override x.delete () = ()

